<%- content_for :head do -%>
  <script type="text/javascript" charset="utf-8">
	factoparcelleForm = new Subform('<%= escape_javascript(render(:partial => "factoparcelle", :object => Factoparcelle.new, :locals => {:index => "INDEX"})) %>',<%= @facture.factoparcelles.length %>,'factoparcelles');
  </script>
<%- end -%>

<p>
  <%= link_to_function "Show/Hide Params", visual_effect(:toggle_blind, :params, :duration => "0.1") %>
</p>
<div id="params" style="display:none;">
  <%= debug params %>
</div>

<%= render :partial => "error_messages", :object => @facture, :locals => {:order => [:name, :factoparcelles, :all]} %>

<% form_for @facture do |f| -%>

<fieldset>
  <legend>Traitement</legend>
	<table>
	<tr>
		<td>Nom : </td>
		<td><%= f.text_field :name, :size => 10 %></td>
	</tr>
	<tr>
		<td>Prestataire</td>
		<td><%= select("facture", "user_id", User.find(:all).collect{ |c| [ c.name, c.id] }) %></td>
	</tr>
	<tr>
		<td>Cout de la Facture</td>
		<td><%= f.text_field :cout, :size => 3 %> euros</td>
	</tr>
	<tr>
		<td>Categorie: </td>
		<td><%= select("facture", "category_id", Category.find_by_type("facture").collect{ |c| [ c.name, c.id] }) %></td>
	</tr>
	<tr>
		<td>Calcul compta: </td>
		<td><%= select("facture", "factype_id", Factype.find(:all).collect{ |c| [ c.name, c.id] }) %></td>
	</tr>
	</table>
</fieldset>

<fieldset>
  <legend><%= @facture.factoparcelles.length %> Pacelles</legend>
	<div id="factoparcelles">
    <%= render :partial => 'factoparcelle', :collection => @facture.factoparcelles %>
  </div>
  <p><%= link_to_function "Ajouter une Parcelle", "factoparcelleForm.add()" %></p>
  <p>! la somme des taux doit etre egale a 1 !</p>
</fieldset>

<p>
<%= f.submit "Submit" %>
</p>
<% end -%>
